<template>
  <!-- <el-button type="text" @click="dialogVisible = true"
    >Click to open Dialog
  </el-button> -->
  <el-dialog
    v-model="dialogVisible"
    :title="props.title"
    width="724px"
    draggable
  >
    <span>It's a draggable Dialog</span>
    <slot></slot>
    <!-- <template #footer>
      <span class="dialog-footer">
        <el-button @click="dialogVisible = false">Cancel</el-button>
        <el-button type="primary" @click="dialogVisible = false"
          >Confirm</el-button
        >
      </span>
    </template> -->
  </el-dialog>
</template>

<script lang="ts" setup>
import { ref, watch } from 'vue'
const props = defineProps({
  isShow: {
    default: false,
  },
  title: {
    default: '默认标题',
  },
})
const emit = defineEmits(['vShow'])

// console.log('is-show', props.isShow)

const dialogVisible = ref(true)

watch(props, (props) => {
  // console.log('监听到props')
  dialogVisible.value = props.isShow
})
watch(
  dialogVisible,
  (val) => {
    console.log('diagvisible监听到变化')
    emit('vShow', dialogVisible.value)
  },
  { deep: true }
)
</script>
